﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:ctrl="clr-namespace:Waf.MusicManager.Presentation.Controls">

    <Style TargetType="{x:Type ctrl:SearchBox}">
        <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        <Setter Property="Focusable" Value="False"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ctrl:SearchBox}">
                    <Border Background="{TemplateBinding Background}">
                        <Grid>
                            <Border Margin="2,0">
                                <Label Content="{TemplateBinding HintText}" Target="{Binding ElementName=PART_SearchTextBox}" 
                                       Margin="{TemplateBinding Margin}" Padding="{TemplateBinding Padding}">
                                    <Label.Style>
                                        <Style TargetType="Label">
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding Text, ElementName=PART_SearchTextBox}" Value="">
                                                    <Setter Property="Foreground" Value="Gray"/>
                                                </DataTrigger>
                                            </Style.Triggers>
                                            <Setter Property="Foreground" Value="Transparent"/>
                                        </Style>
                                    </Label.Style>
                                </Label>
                            </Border>
                            <TextBox x:Name="PART_SearchTextBox" Text="{Binding Text, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged}" 
                                Margin="{TemplateBinding Margin}" Padding="{TemplateBinding Padding}"
                                Background="Transparent" BorderThickness="0"/>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
</ResourceDictionary>